package com.zhc.dejingapi.job;

import com.zhc.dejingapi.service.upload.IGaogeErpBaseInfoUploadService;
import com.zhc.dejingapi.service.upload.IQingFlowDataDownloadService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;

@Slf4j
@Configuration
public class ERPProdBaseDataToQingJob {

    public  static  boolean isRunning=false;
    private final JdbcTemplate mysqlJdbcTemplate;
    //private final IQingAppInfoService qqingAppInfoService;
    private final IGaogeErpBaseInfoUploadService gaogeErpBaseInfoUploadService;
    private final IQingFlowDataDownloadService qingFlowDataDownloadService;

    public ERPProdBaseDataToQingJob(@Qualifier("mySqlJdbcTemplate")JdbcTemplate mysqlJdbcTemplate1,
                                    IGaogeErpBaseInfoUploadService qqingAppInfoService1, IQingFlowDataDownloadService qingFlowDataDownloadService1) {
        this.mysqlJdbcTemplate = mysqlJdbcTemplate1;
        this.gaogeErpBaseInfoUploadService = qqingAppInfoService1;
        this.qingFlowDataDownloadService = qingFlowDataDownloadService1;
    }

    public  void executeJob(){
        if(isRunning){
            log.info("ERPProdClassToQingJob is running");
            return;
        }
        isRunning=true;
        int i=1;
        if(i==10){
            try {
                gaogeErpBaseInfoUploadService.uploadBomMake();
                gaogeErpBaseInfoUploadService.QueryBomMakeAddActionResult();
            }
            catch (Exception e){
                e.printStackTrace();
                log.error("ERPProdClassToQingJob error",e);
            }
            try {
                gaogeErpBaseInfoUploadService.uploadProductUnit();
                gaogeErpBaseInfoUploadService.QueryProductUnitActionResult();

            }
            catch (Exception e){
                e.printStackTrace();
                log.error("ERPProdClassToQingJob error",e);
            }
            try {

                gaogeErpBaseInfoUploadService.uploadProductClass();
                gaogeErpBaseInfoUploadService.QueryProductClassActionResult();
            }
            catch (Exception e){
                e.printStackTrace();
                log.error("ERPProdClassToQingJob error",e);
            }
            try{


                //gaogeErpBaseInfoUploadService.uploadproductInfo();
                //gaogeErpBaseInfoUploadService.QueryProductInfoActionResult();



            }
            catch (Exception e){
                e.printStackTrace();
                log.error("ERPProdClassToQingJob error",e);
            }
        }

        isRunning=false;
    }
}
